package com.xunwulian.dubbo.service.impl;

import com.alibaba.dubbo.config.annotation.Reference;
import com.xunwulian.base.constant.CmebEntity;
import com.xunwulian.base.constant.CommonErrorCode;
import com.xunwulian.base.entity.AppEntity;
import com.xunwulian.api.dto.BaseResponse;
import com.xunwulian.api.iface.CmebAPI;
import com.xunwulian.dubbo.iface.CmppCmebAPI;
import org.springframework.stereotype.Component;
import com.alibaba.dubbo.config.annotation.Service;

@Service
public class CmebApiImpl implements CmebAPI {

    @Reference
    private CmppCmebAPI cmppCmebAPI;

    @Override
    public BaseResponse queryCardInfo(String msisdn, AppEntity appEntity) {

//        cmppCmebAPI = new Consumer<CmppCmebAPI>().getApi(CmppCmebAPI.class, appEntity.getAppId(), appEntity.getAppId(), appEntity.getRegistryAddress());

        BaseResponse<CmebEntity> response = new BaseResponse<>();
        try {
//
            response = cmppCmebAPI.queryCardInfo(msisdn, appEntity);
        } catch (Exception e) {
            response.setCode(CommonErrorCode.E_CMEB_DUBOO.getType());
            response.setMsg(CommonErrorCode.E_CMEB_DUBOO.getDesc());
            e.printStackTrace();
        }

        return response;
    }
}
